package application

import (
	"ruoyi-go-echo-ddd/internal/domain/model"
	"ruoyi-go-echo-ddd/internal/domain/service"
	"ruoyi-go-echo-ddd/internal/infrastructure/http/request"

	"github.com/labstack/echo/v4"
)

type SysDeptApplication struct {
	service *service.SysDeptService
}

func NewSysDeptApplication(u *service.SysDeptService) *SysDeptApplication {
	return &SysDeptApplication{
		service: u,
	}
}

func (s *SysDeptApplication) Save(e echo.Context, dept *model.Dept) (*model.Dept, error) {
	return s.service.Repo.Save(e.Request().Context(), dept)
}

func (s *SysDeptApplication) Update(e echo.Context, dept *model.Dept) (*model.Dept, error) {
	return s.service.Repo.Update(e.Request().Context(), dept)
}

func (s *SysDeptApplication) SelectById(e echo.Context, id int64) (*model.Dept, error) {
	return s.service.Repo.SelectById(e.Request().Context(), id)
}

func (s *SysDeptApplication) CheckDept(e echo.Context, deptId int64) (bool, error) {
	return s.service.Repo.CheckDept(e.Request().Context(), deptId)
}

func (s *SysDeptApplication) BatchSave(e echo.Context, list []*model.Dept) ([]int64, error) {
	return s.service.Repo.BatchSave(e.Request().Context(), list)
}

func (s *SysDeptApplication) BatchSaveByList(e echo.Context, list []*request.DeptInsert) ([]int64, error) {
	return s.service.Repo.BatchSaveByList(e.Request().Context(), list)
}

func (s *SysDeptApplication) SelectDeptList(e echo.Context, param *request.DeptPageParam) ([]*model.Dept, error) {
	return s.service.Repo.SelectDeptList(e.Request().Context(), param)
}

func (s *SysDeptApplication) SelectPage(e echo.Context, param *request.DeptPageParam) ([]*model.Dept, int64, int64, error) {
	return s.service.Repo.SelectPage(e.Request().Context(), param)
}

func (s *SysDeptApplication) BatchDelete(e echo.Context, ids []any) (int64, error) {
	return s.service.Repo.BatchDelete(e.Request().Context(), ids)
}

func (s *SysDeptApplication) SelectListByDept(e echo.Context, dept *model.Dept) ([]*model.Dept, error) {
	return s.service.Repo.SelectListByDept(e.Request().Context(), dept)
}

func (s *SysDeptApplication) BuildDeptTree(list []*model.Dept) ([]*model.Dept, error) {
	return s.service.Repo.BuildDeptTree(list)
}

func (s *SysDeptApplication) BuildDeptTreeSelect(list []*model.Dept) []*model.TreeSelect {
	return s.service.Repo.BuildDeptTreeSelect(list)
}

func (s *SysDeptApplication) SelectListByRoleId(e echo.Context, roleId int64) ([]int64, error) {
	return s.service.Repo.SelectListByRoleId(e.Request().Context(), roleId)
}

func (s *SysDeptApplication) SelectAll(e echo.Context) ([]*model.Dept, error) {
	return s.service.Repo.SelectAll(e.Request().Context())
}
